package com.senthink.gl.business.fault;

import lombok.Getter;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 设备开关状态枚举类
 *
 * @author yuanpeng@senthink.com
 * @data 2017/12/5
 */
@Getter
public enum SwitchEnum {

    /**
     * 开
     */
    ON("ON", "开"),

    /**
     * 关
     */
    OFF("OFF", "关"),

    /**
     * 调整亮度和色温
     */
    LIGHT_AND_COLOR("LIGHT_AND_COLOR", "不启用");

    private String command;

    private String name;

    SwitchEnum(String command, String name) {
        this.command = command;
        this.name = name;
    }

    private static final Map<String, SwitchEnum> pool = new ConcurrentHashMap<>();






    /**
     * 是否开
     *
     * @param swi
     * @return
     */
    public static boolean isOn(String swi) {
        switch (swi) {
            case "ON":
                return true;
            case "OFF":
                return false;
            case "LIGHT_AND_COLOR":
                return false;
            default:
                throw new IllegalArgumentException("No such switch type!");
        }
    }
}
